# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface


from model import booksInfo


class BooksspiderPipeline:

    def process_item(self, item, spider):
        print("保存数据")
        book_info = booksInfo()
        book_info.book_name = item['book_name']
        book_info.book_author = item['book_author']
        book_info.book_abstract = item['book_abstract']
        book_info.book_type = item['book_type']
        book_info.book_label = item['book_label']
        book_info.book_image = item['book_image']
        book_info.book_link = item['book_link']
        book_info.book_score = item['book_score']
        book_info.save()
        print("保存成功")
        return item
